#include "Sphere.h"
#include "Scene.h"

ConcreteElementLoader<Sphere> *loader = new ConcreteElementLoader<Sphere>();

Sphere::Sphere(TiXmlElement *elem) { // TODO IMPLEMENT EXCEPTIONS
	if( elem != NULL ) {
		if( elem->QueryFloatAttribute("radius", &radius) == TIXML_SUCCESS &&
			elem->QueryIntAttribute("slices", &slices) == TIXML_SUCCESS &&
			elem->QueryIntAttribute("stacks", &stacks) == TIXML_SUCCESS) {
			#ifdef DEBUG
			printf("Sphere read: radius = %0.1f, slices = %d, stacks = %d\n", radius, slices, stacks);
			#endif
		}
	}
}

void Sphere::displayElement() {
	glBegin(GL_POLYGON);
		gluSphere( Scene::glQ, 
			radius,
			slices,
			stacks);
	glEnd();
}